package wtc.stu.method;

import wtc.stu.entity.StuEntity;
import java.util.List;

public class ScoreImpl implements Interface {
    @Override
    public void methodSelect() {
        System.out.println("学生信息管理系统>>>>全查询分数信息");
        System.out.println("分数编号\t分数\t学生编号\t备注信息");
        List<StuEntity> ar = daoScore.getAll();
        for (StuEntity stuEntity : ar) {
            System.out.println(
                    "" + stuEntity.getScoreId() + "\t" + stuEntity.getScore() + "\t" + stuEntity.getSid() + "\t" + stuEntity.getScoreRemark() + "");
        }
        System.out.println("显示完毕 ！");
    }

    @Override
    public void methodInsert() {
        System.out.println("学生信息管理系统>>>>增加分数信息");
        System.out.println("请输入要增加的分数随对应的学生：");
        System.out.println("以下是你可以选择的学生：");
        System.out.println("学生编号\t学生姓名\t备注信息");
        List<StuEntity> ar = daoStu.getAll();
        for (StuEntity stuEntity : ar) {
            System.out.println(
                    "" + stuEntity.getSid() + "\t" + stuEntity.getSname() + "\t" + stuEntity.getSremark() + "");
        }
        System.out.println("输入学生编号即可：");
        int sid = sa.nextInt();
        System.out.println("请输入要增加的分数：");
        int score = sa.nextInt();
        System.out.println("请输入要增加的分数备注信息：");
        String scoreRemark = sa.next();
        // 封装
        StuEntity add = new StuEntity();
        add.setScoreRemark(scoreRemark);
        add.setScore(score);
        add.setSid(sid);
        daoScore.addStu(add);
        System.out.println("增加成功！");
    }

    @Override
    public void methodUpdate() {
        System.out.println("学生信息管理系统>>>>全查询分数信息");
        System.out.println("分数编号\t分数\t学生编号\t备注信息");
        /************ 第一步 ***************/
        List<StuEntity> ar = daoScore.getAll();
        for (StuEntity stuEntity : ar) {
            System.out.println(
                    "" + stuEntity.getScoreId() + "\t" + stuEntity.getScore() + "\t" + stuEntity.getSid() + "\t" + stuEntity.getScoreRemark() + "");
        }
        System.out.println("显示完毕 ！");
        System.out.println("以上是你可以修改的分数信息，请输入你要修改的分数的编号：");
        /*********** 第二步 **************/
        int scoreId = sa.nextInt();
        StuEntity myScore = daoScore.getOneById(scoreId);
        System.out.println("请你确认以下分数信息是否是你要修改的：");
        System.out.println("" + myScore.getScoreId() + "\t" + myScore.getScore() +
                "\t" + myScore.getSid() + "\t" + myScore.getScoreRemark() + "");
        /*********** 第三步 **************/
        System.out.println("请输入修改后的分数：");
        int newScore = sa.nextInt();
        System.out.println("请输入修改后的分数所对应的学生编号：");
        int newSid = sa.nextInt();
        System.out.println("请输入要修改分数备注：");
        String newScoreRemark = sa.next();
        StuEntity last = new StuEntity();
        last.setSid(newSid);
        last.setScore(newScore);
        last.setScoreRemark(newScoreRemark);
        last.setScoreId(scoreId);
        /************* 第四步 ****************/
        daoScore.updateStu(last);
        System.out.println("修改完毕 ！");
    }

    @Override
    public void methodDelete() {
        System.out.println("学生信息管理系统>>>>全查询分数信息");
        System.out.println("分数编号\t分数\t学生编号\t备注信息");
        /************ 第一步 ***************/
        List<StuEntity> ar = daoScore.getAll();
        for (StuEntity stuEntity : ar) {
            System.out.println(
                    "" + stuEntity.getScoreId() + "\t" + stuEntity.getScore() + "\t" + stuEntity.getSid() +
                            "\t" + stuEntity.getScoreRemark() + "");
        }
        System.out.println("显示完毕 ！");
        System.out.println("以上是你可以删除的分数信息，请输入你要删除的分数信息的编号：");
        /************ 第二步 **************/
        int delId = sa.nextInt();
        StuEntity delScore = daoScore.getOneById(delId);
        System.out.println("请你确认以下分数信息是否是你要删除的：");
        System.out.println(
                "" + delScore.getScoreId() + "\t" + delScore.getScore() + "\t" + delScore.getSid() +
                        "\t" + delScore.getScoreRemark() + "");
        /*********** 第三步 **************/
        daoScore.delStu(delId);
        System.out.println("删除完毕！");
    }
}
